import * as types from '../mutation-types';

const state = {
  isLoading: false,

  lessonPopup: false,
  helpPopup: false,
  integPopup: false,
  developPopup: false,
  demoPopup: false,

  direction:'forward',
}

const actions = {
  updateLoadingStatus({
    commit
  }, payload) {
    commit(types.COMMON_LOADING_STATUS, payload)
  },
  updateLessonPopup({
    commit
  }, payload) {
    commit(types.COMMON_LESSON_POPUP, payload)
  },
  updateHelpPopup({
    commit
  }, payload) {
    commit(types.COMMON_HELP_POPUP, payload)
  },
  updateIntegPopup({
    commit
  }, payload) {
    commit(types.COMMON_INTEG_POPUP, payload)
  },
  updateDevelopPopup({
    commit
  }, payload) {
    commit(types.COMMON_DEVELOP_POPUP, payload)
  },
  updateDemoPopup({
    commit
  }, payload) {
    commit(types.COMMON_DEMO_POPUP, payload)
  },

  updateDirection({ commit }, status) {
    commit(types.UPDATE_DIRECTION, status)
  },
}

const getters = {
  isLoading: state => state.isLoading,
  lessonPopup: state => state.lessonPopup,
  helpPopup: state => state.helpPopup,
  integPopup: state => state.integPopup,
  developPopup: state => state.developPopup,
  demoPopup: state => state.demoPopup,

  direction: state => state.direction,
}

const mutations = {
  [types.COMMON_LOADING_STATUS](state, payload) {
    state.isLoading = payload.isLoading
  },
  [types.COMMON_LESSON_POPUP](state, payload) {
    state.lessonPopup = payload.lessonPopup
  },
  [types.COMMON_HELP_POPUP](state, payload) {
    state.helpPopup = payload.helpPopup
  },
  [types.COMMON_INTEG_POPUP](state, payload) {
    state.integPopup = payload.integPopup
  },
  [types.COMMON_DEVELOP_POPUP](state, payload) {
    state.developPopup = payload.developPopup
  },
  [types.COMMON_DEMO_POPUP](state, payload) {
    state.demoPopup = payload.demoPopup
  },
  [types.UPDATE_DIRECTION](state, payload) {
    state.direction = payload.direction
  },
}

export default {
  state,
  actions,
  getters,
  mutations,
}
